home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-06-19 | 2.7 KB | 116 lines | [TEXT/CWIE] |
- // FileCopier.h
-
- #ifndef FileCopier_h
- #define FileCopier_h
-
- #ifndef FileCreator_h
- #include "FileCreator.h"
- #endif
- #ifndef FileOutStream_h
- #include "FileOutStream.h"
- #endif
- #ifndef FileOpener_h
- #include "FileOpener.h"
- #endif
- #ifndef FileInStream_h
- #include "FileInStream.h"
- #endif
- #ifndef FileCloser_h
- #include "FileCloser.h"
- #endif
- #ifndef BufferOfSize_h
- #include "BufferOfSize.h"
- #endif
- #ifndef ConstBufferMaster_h
- #include "ConstBufferMaster.h"
- #endif
- #ifndef TaskSequencer_h
- #include "TaskSequencer.h"
- #endif
- #ifndef TaskStep_h
- #include "TaskStep.h"
- #endif
- #ifndef Race_h
- #include "Race.h"
- #endif
- #ifndef InputPump_h
- #include "InputPump.h"
- #endif
- #ifndef OutputPump_h
- #include "OutputPump.h"
- #endif
- #ifndef Pipe_h
- #include "Pipe.h"
- #endif
- #ifndef FileWritingPath_h
- #include "FileWritingPath.h"
- #endif
- #ifndef CatInfoChanger_h
- #include "CatInfoChanger.h"
- #endif
-
- /*
- This is an off-the-cuff file copying Task, which may serve as an example.
- In some ways it's an example of poor practice: it checks no errors,
- doesn't die when dying is set, and doesn't use PBAllocate. Also,
- it floods the File Manager so much that other processes can hardly
- get a call in edgewise.
- */
-
- class FileCopier
- {
- private:
- const FSSpec *sourceFile;
- const FSSpec *destinationFile;
- uint32 dataCopied;
-
- FileReadingPath sourcePath;
- FileWritingPath destinationPath;
-
- FileCreator create;
- FileOpener open;
- FileCloser close;
- FileInStream inStream;
- FileOutStream outStream;
- CatInfoChanger info;
-
- InputPump pumpIn;
- OutputPump pumpOut;
- Race2 race;
-
- uint8 buffer[1024 * 1024 + 4096];
- Pipe pipe;
-
- TaskSequencer<FileCopier> sequence;
- typedef TaskStep<FileCopier> Step;
-
- Step CreateDestination( bool dying, DeferredTaskTime );
-
- Step GetSourceInfo( bool dying, DeferredTaskTime );
- Step SetDestinationInfo( bool dying, DeferredTaskTime );
-
- Step OpenDestinationData( bool dying, DeferredTaskTime );
- Step OpenSourceData( bool dying, DeferredTaskTime );
- Step CopyData( bool dying, DeferredTaskTime );
- Step CloseSourceData( bool dying, DeferredTaskTime );
- Step CloseDestinationData( bool dying, DeferredTaskTime );
-
- Step OpenDestinationResources( bool dying, DeferredTaskTime );
- Step OpenSourceResources( bool dying, DeferredTaskTime );
- Step CopyResources( bool dying, DeferredTaskTime );
- Step CloseSourceResources( bool dying, DeferredTaskTime );
- Step CloseDestinationResources( bool dying, DeferredTaskTime );
-
- public:
- FileCopier();
-
- Task *operator()( const FSSpec& source,
- const FSSpec& destination );
-
- uint32 Position() const { return outStream.Position() + dataCopied; }
- uint32 MaxPosition() const { return info.hFileInfo.ioFlLgLen
- + info.hFileInfo.ioFlRLgLen; }
- };
-
- #endif
-